<?php
/**
 * @version		$Id: helper.php 21421 2011-06-03 07:21:02Z infograf768 $
 * @package		Joomla.Site
 * @subpackage	mod_login
 * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

class modWrdmetroHelper
{
	function getItemsCategory($a,$b,$c){
		$a = intval($a);
		$b = intval($b);
		$c = intval($c);
		
		$db = JFactory::getDbo();
		$query = 'SELECT id,title,introtext,catid FROM #__content WHERE state = 1 AND featured = 1 AND catid IN( '.$a.','.$b.','.$c.') order by rand() LIMIT 14';
		
		return $db->setQuery($query)->loadObjectList();
	}
	
	function getItemsImage($id){
		$db = JFactory::getDbo();
		$query = 'SELECT url,description FROM #__attachments WHERE state = 1 AND parent_id = '.$id;
		
		return $db->setQuery($query)->loadObjectList();
	}
	
	function getItemProduct(){
		$db = JFactory::getDbo();
		$query = 'SELECT * FROM #__wrd_products WHERE published = 1 AND quantity > 0 ORDER BY rand() LIMIT 1';
		return $db->setQuery($query)->loadObject();
	}
	
	function getProductImage($id){
		$db = JFactory::getDbo();
		$query = 'SELECT * FROM #__wrd_file WHERE product_id = '.$id.' AND type = "image1" LIMIT 1';
		return $db->setQuery($query)->loadObject();
	}
}
